local fuzheng = fk.CreateSkill {
  name = "lingling__fuzheng",
}

Fk:loadTranslationTable {
  ["lingling__fuzheng"] = "斧正",
  [":lingling__fuzheng"] = "当你使用【杀】对其他角色造成伤害后，你可以选择一项令其：摸两张牌并翻面；将手牌调整至体力上限。",

  ["#lingling__fuzheng-choice"] = "斧正：你可以令 %dest 执行一项",
  ["lingling__fuzheng_turnover"] = "摸两张牌并翻面",
  ["lingling__fuzheng_draw"] = "将手牌调整至体力上限",
}

fuzheng:addEffect(fk.Damage, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(fuzheng.name) and
        data.card and data.card.trueName == "slash" and
        not data.to.dead and data.to ~= player
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local choices = { "lingling__fuzheng_turnover", "Cancel" }
    if data.to:getHandcardNum() ~= data.to.hp then
      table.insert(choices, 2, "lingling__fuzheng_draw")
    end
    local choice = room:askToChoice(player, {
      choices = choices,
      skill_name = fuzheng.name,
      prompt = "#lingling__fuzheng-choice::" .. data.to.id,
    })
    if choice ~= "Cancel" then
      event:setCostData(self, { tos = { data.to }, choice = choice })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local to = data.to
    local choice = event:getCostData(self).choice
    if choice == "lingling__fuzheng_turnover" then
      to:drawCards(2, fuzheng.name)
      if to.dead then return end
      to:turnOver()
    else
      local n = to:getHandcardNum() - to.maxHp
      if n > 0 then
        player.room:askToDiscard(to, {
          min_num = n,
          max_num = n,
          include_equip = false,
          skill_name = fuzheng.name,
          cancelable = false,
        })
      else
        to:drawCards(-n, fuzheng.name)
      end
    end
  end
})

return fuzheng
